{% extends 'base.html' %}
{% load humanize %}

{% block extra_head %}
<title>{{archive.title}} -- {{archive.category.name}} - {{env_blog.name}}</title>

<style type='text/css'>
    .archive h2{
        font-size:15px;
        margin:0 0 12px;
    }
    .archive .info{
        color:silver;
    }
    .archive .para{
        margin:1em 1em;
    }
    .comment{
        margin-bottom:10px;
    }
    .comment img{
        width:40px;
        height:40px;
        float:left;
        margin-right:10px;
    }
    .comment .author_info{
        color:gray;
        margin-bottom:5px;
    }
    .comment .content{
        margin-left:50px;
    }
    .author{
        color:#444444;
    }
    body{
        position:relative;
    }
</style>

<script type='text/javascript'>
    function sign_top(){
        window.location = '{{archive.category.get_absolute_url}}';
    }
    function sign_bottom(){
        window.location = '{{archive.get_absolute_url}}#comments';
    }
    function sign_right(){
        window.location = '{{archive.get_absolute_url}}/next';
    }
    function sign_left(){
        window.location = '{{archive.get_absolute_url}}/prev';
    }

    $(document).ready(function(){
        $('a.delete').click(function(){
            if(window.confirm('确认删除此文章(此操作不可撤销！)?','删除文章')){
                return true;
            }else{
                return false;
            }
            });

        //if( !($.browser.msie && $.browser.version == '6.0') ){
            registerMouseSign('.archive',"{'top':sign_top,'bottom':sign_bottom,'left':sign_left,'right':sign_right }")
         //   }
    });

</script>
{% endblock %}

{% block content %}

<!-- 文章区 -->
<div class='archive'>
    <h2>{{archive.title}}</h2>
    <div class='info'>
        分类-<a href='{{archive.category.get_absolute_url}}'>{{archive.category.name}}</a>
        {{archive.pub_date|naturalday}} {{archive.pub_date|date:"H:i"}}
        {{archive.view_nums}} Views {{archive.comments.count}} Comments
        {% if is_admin %}
        &nbsp;&nbsp;<a href='/archive/{{archive.key.id}}/edit'>Edit</a>
        <a class='delete' href='/archive/{{archive.key.id}}/delete'>Delete</a>
        {% endif %}
    </div>
    <div class='tags'>
        标签：{% for tag in tags  %} <a class='tag' href='/tag/{{tag}}' >{{tag}}</a>{% endfor %}
    </div>
    <div class='para'>
        {% autoescape off %}
        {{archive.content}}
            {% autoescape on %}
            {% endautoescape %}
        {% endautoescape %}
    </div>
</div>

<div id='comments' class='comments'>
    <h3 class='dot'><span>COMMENTS | 评论</span></h3>
    {% for comment in archive.query_comments %}
    <div id='comment_{{comment.key.id}}' class='comment'>
        <img src='{{comment.avatar}}'></img>
        <div class='author_info'>
            {% if comment.web %}
            <a class='author' id='' href='{{comment.web}}'>{{comment.name}}</a>
            {% else %}
            <span class='author'>{{comment.name}}</span>
            {% endif %}

            {{ comment.date|naturalday }} {{comment.date|date:"H:i"}}
            {% ifequal comment.source 'wap' %}
            <span class='source' style='font-style:italic'>  -- 通过手机 </span>
            {% endifequal %}
        </div>
        <div class='content'>
        {{comment.content|linebreaksbr}}
        </div>
        <div class='clear'></div>
    </div>
    <div class='clear'></div>
    {% endfor %}
</div>

<div class='add_comment'>
    <h3 class='dot'><span>留下个小脚印吧</span></h3>
    <form class='model' action='/archive/{{archive.key.id}}/comment' method='POST'>
    {{ comment_form.as_p }}
    <input type='submit' class='submit' value='贴上去'></input>
    </form>
    <a href='/login'>使用Google账号登录</a>
</div>
{% endblock %}
